#!/usr/bin/evn python
# -*- coding: UTF-8 -*-
# @File: start_page.py
# @Author: fy
# @date: 2021/9/7 10:01
from appium.webdriver.common.mobileby import MobileBy

from pages.base_page import BasePage
from pages.contacts_page import ContactsPage


class StartPage(BasePage):
    _contact_tab_locator = (MobileBy.XPATH, '//*[@text="通讯录"]')
    _message_locator = (MobileBy.XPATH, '//*[contains(@text, "消息")]')

    def goto_contacts_page(self):
        '''
        点击通讯录，跳转到通讯录页
        :return:
        '''
        # self.startApp()
        self.find_and_click(self._contact_tab_locator)
        return ContactsPage(self.driver)

    def isStartPage(self):
        '''
        首页独一无二的元素来定位首页
        :return:
        '''
        eles = self.find_elements(self._message_locator, 5)
        if eles and len(eles) >= 2:
            return True
        else:
            return False
